﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.ComponentModel;
using System.Collections.Generic;
using System.Windows.Data;
using System.IO;
using System.Linq;

using Cinch;
using MEFedMVVM.ViewModelLocator;
using MEFedMVVM.Services.Contracts;
using MEFedMVVM.Common;


namespace Anata.Client
{
    /// <summary>
    /// </summary>
    public class LayananCabangFilterViewModel : ViewModelBase
    {
        #region Data
        #region Data.Primitives
        private DispatcherNotifiedObservableCollection<LayananCabangViewModel> layananCabangs;
        private ICollectionView layananCabangsCV;
        #endregion

        #region Data.Rules
        #endregion

        #region Data.VMs
        #endregion

        #region Data.Services
        private IMessageBoxService messageBoxService;
        private IUIVisualizerService uiVisualizerService;
        #endregion
        #endregion

        #region Ctor
        [ImportingConstructor]
        public LayananCabangFilterViewModel(
            IMessageBoxService messageBoxService,
            IUIVisualizerService uiVisualizerService)
        {
            #region Constructor.SetupServices
            this.messageBoxService = messageBoxService;
            this.uiVisualizerService = uiVisualizerService;
            //this.viewAwareStatusService = viewAwareStatusService;
            //this.viewAwareStatusService.ViewLoaded += ViewAwareStatusService_ViewLoaded;
            #endregion

            #region Constructor.SetupCommands
            LayananCabangSelectCommand = new SimpleCommand<Object, Object>(CanExecuteLayananCabangSelectCommand, ExecuteLayananCabangSelectCommand);
            #endregion

            #region Constructor.CreateDataWrappers
            #endregion

            #region Constructor.CreateValidationRules
            #endregion

            #region Constructor.SetupCollections
            LayananCabangs = new DispatcherNotifiedObservableCollection<LayananCabangViewModel>();
            LayananCabangsCV = CollectionViewSource.GetDefaultView(LayananCabangs);
            #endregion

            //debug use
            LayananCabangViewModel lcvm = null;
            for (int i = 1; i < 11; i++)
            {
                lcvm = new LayananCabangViewModel(
                    messageBoxService,
                    uiVisualizerService);
                lcvm.IdLayanan.DataValue = i;
                lcvm.NamaLayanan.DataValue = "layanan " + i;
                lcvm.IdCabang.DataValue = 1;
                lcvm.Harga.DataValue = i * 1000;
                LayananCabangs.Add(lcvm);
            }
            //LoadedKonsumenCV = CollectionViewSource.GetDefaultView(loadedKonsumen);
            //debug use

            //commands, SimpleCommand<T1,T2> T1 is CanExecute parameter type, and T2 is Execute type
        }
        #endregion

        #region Public Properties
        #region Public.Commands
        public SimpleCommand<Object, Object> LayananCabangSelectCommand { get; set; }
        #endregion

        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs layananCabangsChangeArgs =
            ObservableHelper.CreateArgs<LayananCabangFilterViewModel>(x => x.LayananCabangs);
        public DispatcherNotifiedObservableCollection<LayananCabangViewModel> LayananCabangs
        {
            get { return layananCabangs; }
            set
            {
                layananCabangs = value;
                NotifyPropertyChanged(layananCabangsChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs layananCabangsCVChangeArgs =
            ObservableHelper.CreateArgs<LayananCabangFilterViewModel>(x => x.LayananCabangsCV);
        public ICollectionView LayananCabangsCV
        {
            get { return layananCabangsCV; }
            set
            {
                layananCabangsCV = value;
                NotifyPropertyChanged(layananCabangsCVChangeArgs);
            }
        }
        #endregion

        #region Command Handlers
        private bool CanExecuteLayananCabangSelectCommand(Object args)
        {
            return true;
        }
        /// <summary>
        /// </summary>
        private void ExecuteLayananCabangSelectCommand(Object args)
        {
        }

        #endregion

        #region Private Methods
        //private void ViewAwareStatusService_ViewLoaded()
        //{
        //    konsumens = new DispatcherNotifiedObservableCollection<KonsumenViewModel>();
        //    KonsumenViewModel kvm = null;
        //    for (int i = 0; i < 10; i++)
        //    {
        //        kvm = new KonsumenViewModel();
        //        kvm.IdKonsumen.DataValue = i;
        //        kvm.Nama.DataValue = "Konsumen " + i;
        //        kvm.Alamat.DataValue = "Alamat " + i;
        //        konsumens.Add(new KonsumenViewModel());
        //    }
        //    //LoadedKonsumenCV = CollectionViewSource.GetDefaultView(loadedKonsumen);
        //}
        #endregion
    }

}
